convert field var page to .ui

Change-Id: I56be21c0e5b74b03b0c7f8cca873fc4fd553f3a7
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 4ba8b0cd..987454b 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -391,6 +391,10 @@
                        generic-name="URLBox" parent="VclComboBoxText"
                        icon-name="widget-gtk-comboboxtext"/>

    <glade-widget-class title="SelectionListBox" name="swuilo-SelectionListBox"
                        generic-name="SelectionListBox" parent="VclComboBoxText"
                        icon-name="widget-gtk-comboboxtext"/>

    <glade-widget-class title="PropertyControl" name="sdlo-PropertyControl"
                        generic-name="PropertyControl" parent="VclComboBoxText"
                        icon-name="widget-gtk-comboboxtext"/>
diff --git a/sw/AllLangResTarget_sw.mk b/sw/AllLangResTarget_sw.mk
index aa16280..7aec66a 100644
--- a/sw/AllLangResTarget_sw.mk
+++ b/sw/AllLangResTarget_sw.mk
@@ -104,7 +104,6 @@
    sw/source/ui/fldui/flddb.src \
    sw/source/ui/fldui/fldtdlg.src \
    sw/source/ui/fldui/fldui.src \
    sw/source/ui/fldui/fldvar.src \
    sw/source/ui/frmdlg/frmpage.src \
    sw/source/ui/frmdlg/frmui.src \
    sw/source/ui/globdoc/globdoc.src \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index fe4edbd..38f3226 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -94,6 +94,7 @@
	sw/uiconfig/swriter/ui/flddocumentpage \
	sw/uiconfig/swriter/ui/fldfuncpage \
	sw/uiconfig/swriter/ui/fldrefpage \
	sw/uiconfig/swriter/ui/fldvarpage \
	sw/uiconfig/swriter/ui/formatsectiondialog \
	sw/uiconfig/swriter/ui/formattablepage \
	sw/uiconfig/swriter/ui/footendnotedialog \
diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h
index b302a0a6..5d24310 100644
--- a/sw/inc/helpid.h
+++ b/sw/inc/helpid.h
@@ -112,8 +112,6 @@
#define HID_NAVI_CONTENT                                        "SW_HID_NAVI_CONTENT"
#define HID_NAVI_GLOBAL                                         "SW_HID_NAVI_GLOBAL"
#define HID_LTEMPL_NUMBERING                                    "SW_HID_LTEMPL_NUMBERING"
#define HID_FLDVAR_APPLY                                        "SW_HID_FLDVAR_APPLY"
#define HID_FLDVAR_DELETE                                       "SW_HID_FLDVAR_DELETE"
#define HID_FLDEDT_ADDRESS                                      "SW_HID_FLDEDT_ADDRESS"
#define HID_SORT_ACTION                                         "SW_HID_SORT_ACTION"
#define HID_SORT_AUTHOR                                         "SW_HID_SORT_AUTHOR"
@@ -144,7 +142,6 @@
#define HID_COND_COLL                                           "SW_HID_COND_COLL"

#define HID_FLD_DB                                              "SW_HID_FLD_DB"
#define HID_FLD_VAR                                             "SW_HID_FLD_VAR"

#define HID_EDIT_FLD_DB                                         "SW_HID_EDIT_FLD_DB"
#define HID_EDIT_FLD_DOKINF                                     "SW_HID_EDIT_FLD_DOKINF"
diff --git a/sw/source/ui/fldui/fldtdlg.hrc b/sw/source/ui/fldui/fldtdlg.hrc
index 0120acb..ca24cc5 100644
--- a/sw/source/ui/fldui/fldtdlg.hrc
+++ b/sw/source/ui/fldui/fldtdlg.hrc
@@ -44,31 +44,7 @@
#define FT_ADDDB            (RC_TP_DB_START + 16)
#define PB_ADDDB            (RC_TP_DB_START + 17)

// Variable-TabPage:
#define RC_TP_VAR_START     (RC_TP_DB_END)
#define FT_VARTYPE          (RC_TP_VAR_START + 1)
#define LB_VARTYPE          (RC_TP_VAR_START + 2)
#define FT_VARSELECTION     (RC_TP_VAR_START + 3)
#define LB_VARSELECTION     (RC_TP_VAR_START + 4)
#define FT_VARNAME          (RC_TP_VAR_START + 5)
#define ED_VARNAME          (RC_TP_VAR_START + 6)
#define FT_VARVALUE         (RC_TP_VAR_START + 7)
#define ED_VARVALUE         (RC_TP_VAR_START + 8)
#define FT_VARFORMAT        (RC_TP_VAR_START + 9)
#define LB_VARNUMFORMAT     (RC_TP_VAR_START + 10)
#define LB_VARFORMAT        (RC_TP_VAR_START + 11)
#define FT_VARCHAPTERHEADER (RC_TP_VAR_START + 12)
#define FT_VARCHAPTERLEVEL  (RC_TP_VAR_START + 13)
#define LB_VARCHAPTERLEVEL  (RC_TP_VAR_START + 14)
#define CB_VARINVISIBLE     (RC_TP_VAR_START + 15)
#define FT_VARSEPARATOR     (RC_TP_VAR_START + 16)
#define ED_VARSEPARATOR     (RC_TP_VAR_START + 17)
#define TBX_VARNEWDEL       (RC_TP_VAR_START + 18)
#define BT_VARAPPLY         (RC_TP_VAR_START + 19)
#define BT_VARDELETE        (RC_TP_VAR_START + 20)
#define RC_TP_VAR_END       (RC_TP_VAR_START + 21)

#define RC_TP_END           (RC_TP_VAR_END)
#define RC_TP_END           (RC_TP_DB_END)

// Strings ------------------------------------------------------------------

diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 292a2de..89da12e 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -38,47 +38,50 @@
#define USER_DATA_VERSION_1 "1"
#define USER_DATA_VERSION USER_DATA_VERSION_1

SwFldVarPage::SwFldVarPage(Window* pParent, const SfxItemSet& rCoreSet ) :
    SwFldPage       ( pParent, SW_RES( TP_FLD_VAR ), rCoreSet ),
    aTypeFT         (this, SW_RES(FT_VARTYPE)),
    aTypeLB         (this, SW_RES(LB_VARTYPE)),
    aSelectionFT    (this, SW_RES(FT_VARSELECTION)),
    aSelectionLB    (this, SW_RES(LB_VARSELECTION)),
    aNameFT         (this, SW_RES(FT_VARNAME)),
    aNameED         (this, SW_RES(ED_VARNAME)),
    aValueFT        (this, SW_RES(FT_VARVALUE)),
    aValueED        (this, SW_RES(ED_VARVALUE)),
    aFormatFT       (this, SW_RES(FT_VARFORMAT)),
    aNumFormatLB    (this, SW_RES(LB_VARNUMFORMAT)),
    aFormatLB       (this, SW_RES(LB_VARFORMAT)),
    aChapterHeaderFT(this, SW_RES(FT_VARCHAPTERHEADER)),
    aChapterLevelFT (this, SW_RES(FT_VARCHAPTERLEVEL)),
    aChapterLevelLB (this, SW_RES(LB_VARCHAPTERLEVEL)),
    aInvisibleCB    (this, SW_RES(CB_VARINVISIBLE)),
    aSeparatorFT    (this, SW_RES(FT_VARSEPARATOR)),
    aSeparatorED    (this, SW_RES(ED_VARSEPARATOR)),
    aNewDelTBX      (this, SW_RES(TBX_VARNEWDEL)),
    bInit           (sal_True)
SwFldVarPage::SwFldVarPage(Window* pParent, const SfxItemSet& rCoreSet )
    : SwFldPage(pParent, "FldVarPage",
        "modules/swriter/ui/fldvarpage.ui", rCoreSet)
    , bInit(true)
{
    FreeResource();
    get(m_pTypeLB, "type");
    get(m_pSelection, "selectframe");
    get(m_pSelectionLB, "select");
    get(m_pFormat, "formatframe");
    get(m_pChapterFrame, "chapterframe");
    get(m_pNameFT, "nameft");
    get(m_pNameED, "name");
    get(m_pValueFT, "valueft");
    get(m_pValueED, "value");
    get(m_pNumFormatLB, "numformat");
    get(m_pFormatLB, "format");
    get(m_pChapterLevelLB, "level");
    get(m_pInvisibleCB, "invisible");
    get(m_pSeparatorFT, "separatorft");
    get(m_pSeparatorED, "separator");
    get(m_pNewDelTBX, "toolbar");

    aNewDelTBX.SetSizePixel( aNewDelTBX.CalcWindowSizePixel() );
    long nHeight = m_pTypeLB->GetTextHeight() * 20;
    m_pTypeLB->set_height_request(nHeight);
    m_pSelectionLB->set_height_request(nHeight);
    m_pFormatLB->set_height_request(nHeight/2);

    long nDelta = ( aValueED.GetSizePixel().Height() -
                    aNewDelTBX.GetSizePixel().Height() ) / 2;
    Point aNewPnt = aNewDelTBX.GetPosPixel();
    aNewPnt.Y() += nDelta;
    aNewDelTBX.SetPosPixel( aNewPnt );
    long nWidth = m_pTypeLB->LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), MapMode(MAP_APPFONT)).Width();
    m_pTypeLB->set_width_request(nWidth);
    m_pSelectionLB->set_width_request(nWidth);
    m_pFormatLB->set_width_request(nWidth);

    sOldValueFT = aValueFT.GetText();
    sOldNameFT = aNameFT.GetText();
    m_nApplyId = m_pNewDelTBX->GetItemId("apply");
    m_nDeleteId = m_pNewDelTBX->GetItemId("delete");

    sOldValueFT = m_pValueFT->GetText();
    sOldNameFT = m_pNameFT->GetText();

    for (sal_uInt16 i = 1; i <= MAXLEVEL; i++)
        aChapterLevelLB.InsertEntry(OUString::number(i));
        m_pChapterLevelLB->InsertEntry(OUString::number(i));

    aChapterLevelLB.SelectEntryPos(0);
    m_pChapterLevelLB->SelectEntryPos(0);
    //enable 'active' language selection
    aNumFormatLB.SetShowLanguageControl(sal_True);
    m_pNumFormatLB->SetShowLanguageControl(sal_True);
}

SwFldVarPage::~SwFldVarPage()
@@ -87,12 +90,12 @@

void SwFldVarPage::Reset(const SfxItemSet& )
{
    SavePos(&aTypeLB);
    SavePos(m_pTypeLB);

    Init(); // general initialisation

    aTypeLB.SetUpdateMode(sal_False);
    aTypeLB.Clear();
    m_pTypeLB->SetUpdateMode(sal_False);
    m_pTypeLB->Clear();

    sal_uInt16 nPos, nTypeId;

@@ -104,8 +107,8 @@
        for (short i = rRg.nStart; i < rRg.nEnd; ++i)
        {
            nTypeId = GetFldMgr().GetTypeId(i);
            nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
            aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
            nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(i));
            m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
        }
    }
    else
@@ -114,9 +117,9 @@
        nTypeId = pCurField->GetTypeId();
        if (nTypeId == TYP_SETINPFLD)
            nTypeId = TYP_INPUTFLD;
        nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
        aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
        aNumFormatLB.SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
        nPos = m_pTypeLB->InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
        m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
        m_pNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
        SwWrtShell *pSh = GetWrtShell();
        if(!pSh)
            pSh = ::GetActiveWrtShell();
@@ -124,24 +127,24 @@
        {
            const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
            if(pFormat)
                aNumFormatLB.SetLanguage(pFormat->GetLanguage());
                m_pNumFormatLB->SetLanguage(pFormat->GetLanguage());
        }
    }

    // select old Pos
    RestorePos(&aTypeLB);
    RestorePos(m_pTypeLB);

    aTypeLB.SetDoubleClickHdl       (LINK(this, SwFldVarPage, InsertHdl));
    aTypeLB.SetSelectHdl            (LINK(this, SwFldVarPage, TypeHdl));
    aSelectionLB.SetSelectHdl       (LINK(this, SwFldVarPage, SubTypeHdl));
    aSelectionLB.SetDoubleClickHdl  (LINK(this, SwFldVarPage, InsertHdl));
    aFormatLB.SetDoubleClickHdl     (LINK(this, SwFldVarPage, InsertHdl));
    aNumFormatLB.SetDoubleClickHdl  (LINK(this, SwFldVarPage, InsertHdl));
    aNameED.SetModifyHdl            (LINK(this, SwFldVarPage, ModifyHdl));
    aValueED.SetModifyHdl           (LINK(this, SwFldVarPage, ModifyHdl));
    aNewDelTBX.SetClickHdl          (LINK(this, SwFldVarPage, TBClickHdl));
    aChapterLevelLB.SetSelectHdl    (LINK(this, SwFldVarPage, ChapterHdl));
    aSeparatorED.SetModifyHdl       (LINK(this, SwFldVarPage, SeparatorHdl));
    m_pTypeLB->SetDoubleClickHdl       (LINK(this, SwFldVarPage, InsertHdl));
    m_pTypeLB->SetSelectHdl            (LINK(this, SwFldVarPage, TypeHdl));
    m_pSelectionLB->SetSelectHdl       (LINK(this, SwFldVarPage, SubTypeHdl));
    m_pSelectionLB->SetDoubleClickHdl  (LINK(this, SwFldVarPage, InsertHdl));
    m_pFormatLB->SetDoubleClickHdl     (LINK(this, SwFldVarPage, InsertHdl));
    m_pNumFormatLB->SetDoubleClickHdl  (LINK(this, SwFldVarPage, InsertHdl));
    m_pNameED->SetModifyHdl            (LINK(this, SwFldVarPage, ModifyHdl));
    m_pValueED->SetModifyHdl           (LINK(this, SwFldVarPage, ModifyHdl));
    m_pNewDelTBX->SetClickHdl          (LINK(this, SwFldVarPage, TBClickHdl));
    m_pChapterLevelLB->SetSelectHdl    (LINK(this, SwFldVarPage, ChapterHdl));
    m_pSeparatorED->SetModifyHdl       (LINK(this, SwFldVarPage, SeparatorHdl));

    if( !IsRefresh() )
    {
@@ -152,10 +155,10 @@
            sal_uInt16 nVal = (sal_uInt16)sVal.ToInt32();
            if( USHRT_MAX != nVal )
            {
                for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++)
                    if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
                for(sal_uInt16 i = 0; i < m_pTypeLB->GetEntryCount(); i++)
                    if(nVal == (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(i))
                    {
                        aTypeLB.SelectEntryPos(i);
                        m_pTypeLB->SelectEntryPos(i);
                        break;
                    }
            }
@@ -163,18 +166,18 @@
    }
    TypeHdl(0);

    aTypeLB.SetUpdateMode(sal_True);
    m_pTypeLB->SetUpdateMode(sal_True);

    if (IsFldEdit())
    {
        aSelectionLB.SaveValue();
        aFormatLB.SaveValue();
        nOldFormat = aNumFormatLB.GetFormat();
        aNameED.SaveValue();
        aValueED.SaveValue();
        aInvisibleCB.SaveValue();
        aChapterLevelLB.SaveValue();
        aSeparatorED.SaveValue();
        m_pSelectionLB->SaveValue();
        m_pFormatLB->SaveValue();
        nOldFormat = m_pNumFormatLB->GetFormat();
        m_pNameED->SaveValue();
        m_pValueED->SaveValue();
        m_pInvisibleCB->SaveValue();
        m_pChapterLevelLB->SaveValue();
        m_pSeparatorED->SaveValue();
    }
}

@@ -184,12 +187,12 @@
    const sal_uInt16 nOld = GetTypeSel();

    // current ListBoxPos
    SetTypeSel(aTypeLB.GetSelectEntryPos());
    SetTypeSel(m_pTypeLB->GetSelectEntryPos());

    if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
    {
        SetTypeSel(0);
        aTypeLB.SelectEntryPos(0);
        m_pTypeLB->SelectEntryPos(0);
    }

    if (nOld != GetTypeSel() || nOld == LISTBOX_ENTRY_NOTFOUND)
@@ -197,11 +200,11 @@
        bInit = sal_True;
        if (nOld != LISTBOX_ENTRY_NOTFOUND)
        {
            aNameED.SetText(aEmptyStr);
            aValueED.SetText(aEmptyStr);
            m_pNameED->SetText(aEmptyStr);
            m_pValueED->SetText(aEmptyStr);
        }

        aValueED.SetDropEnable(false);
        m_pValueED->SetDropEnable(false);
        UpdateSubType();    // initialise selection-listboxes
    }

@@ -212,33 +215,33 @@

IMPL_LINK( SwFldVarPage, SubTypeHdl, ListBox *, pBox )
{
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
    sal_uInt16 nSelPos = aSelectionLB.GetSelectEntryPos();
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
    sal_uInt16 nSelPos = m_pSelectionLB->GetSelectEntryPos();

    if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
        nSelPos = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSelPos);
        nSelPos = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nSelPos);

    if (IsFldEdit() && (!pBox || bInit))
    {
        if (nTypeId != TYP_FORMELFLD)
            aNameED.SetText(GetFldMgr().GetCurFldPar1());
            m_pNameED->SetText(GetFldMgr().GetCurFldPar1());

        aValueED.SetText(GetFldMgr().GetCurFldPar2());
        m_pValueED->SetText(GetFldMgr().GetCurFldPar2());
    }

    if (aNameFT.GetText() != OUString(sOldNameFT))
        aNameFT.SetText(sOldNameFT);
    if (aValueFT.GetText() != OUString(sOldValueFT))
        aValueFT.SetText(sOldValueFT);
    if (m_pNameFT->GetText() != OUString(sOldNameFT))
        m_pNameFT->SetText(sOldNameFT);
    if (m_pValueFT->GetText() != OUString(sOldValueFT))
        m_pValueFT->SetText(sOldValueFT);

    aNumFormatLB.SetUpdateMode(sal_False);
    aFormatLB.SetUpdateMode(sal_False);
    m_pNumFormatLB->SetUpdateMode(sal_False);
    m_pFormatLB->SetUpdateMode(sal_False);
    FillFormatLB(nTypeId);

    sal_uInt16 nSize = aFormatLB.GetEntryCount();
    sal_uInt16 nSize = m_pFormatLB->GetEntryCount();

    sal_Bool bValue = sal_False, bName = sal_False, bNumFmt = sal_False,
            bInvisible = sal_False, bSeparator = sal_False, bChapterLevel = sal_False;
            bInvisible = sal_False, bShowChapterFrame = sal_False;
    sal_Bool bFormat = nSize != 0;

    switch (nTypeId)
@@ -255,31 +258,31 @@
                {
                    if (pBox || (bInit && !IsRefresh()))    // only when interacting via mouse
                    {
                        aNameED.SetText(pType->GetName());
                        m_pNameED->SetText(pType->GetName());

                        if (pType->GetType() == UF_STRING)
                        {
                            aValueED.SetText(pType->GetContent());
                            aNumFormatLB.SelectEntryPos(0);
                            m_pValueED->SetText(pType->GetContent());
                            m_pNumFormatLB->SelectEntryPos(0);
                        }
                        else
                            aValueED.SetText(pType->GetContent());
                            m_pValueED->SetText(pType->GetContent());
                    }
                }
                else
                    aValueED.SetText(pType->GetContent());
                    m_pValueED->SetText(pType->GetContent());
            }
            else
            {
                if (pBox)   // only when interacting via mouse
                {
                    aNameED.SetText(aEmptyStr);
                    aValueED.SetText(aEmptyStr);
                    m_pNameED->SetText(aEmptyStr);
                    m_pValueED->SetText(aEmptyStr);
                }
            }
            bValue = bName = bNumFmt = bInvisible = sal_True;

            aValueED.SetDropEnable(true);
            m_pValueED->SetDropEnable(true);
            break;
        }

@@ -292,18 +295,18 @@
                bName = sal_True;
            else
            {
                aNumFormatLB.Clear();
                sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0);
                aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
                aNumFormatLB.SelectEntryPos(0);
                m_pNumFormatLB->Clear();
                sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0);
                m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
                m_pNumFormatLB->SelectEntryPos(0);
            }
            // is there a corresponding SetField
            if (IsFldEdit() || pBox)    // only when interacting via mouse
            {
                if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
                {
                    String sName(aSelectionLB.GetSelectEntry());
                    aNameED.SetText(sName);
                    String sName(m_pSelectionLB->GetSelectEntry());
                    m_pNameED->SetText(sName);

                    if (!IsFldDlgHtmlMode())
                    {
@@ -316,7 +319,7 @@
                                    pSh->GetFldType(RES_SETEXPFLD, sName);

                            if (pSetTyp && pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING)
                                aNumFormatLB.SelectEntryPos(0); // textual
                                m_pNumFormatLB->SelectEntryPos(0); // textual
                        }
                    }
                }
@@ -328,17 +331,17 @@
                // It must be used though because otherwise in GetPar2 only
                // the value calculated by Kalkulator would be displayed
                // (instead of test2 = test + 1)
                aValueED.SetText(((SwSetExpField*)GetCurField())->GetFormula());
                m_pValueED->SetText(((SwSetExpField*)GetCurField())->GetFormula());
            }
            aValueED.SetDropEnable(true);
            m_pValueED->SetDropEnable(true);
            break;

        case TYP_FORMELFLD:
            {
                bValue = sal_True;
                bNumFmt = sal_True;
                aValueFT.SetText(SW_RESSTR(STR_FORMULA));
                aValueED.SetDropEnable(true);
                m_pValueFT->SetText(SW_RESSTR(STR_FORMULA));
                m_pValueED->SetDropEnable(true);
            }
            break;

@@ -346,15 +349,15 @@
            {
                if (!IsFldEdit())
                {
                    aNameED.SetText(aEmptyStr);
                    aValueED.SetText(aEmptyStr);
                    m_pNameED->SetText(aEmptyStr);
                    m_pValueED->SetText(aEmptyStr);
                }

                if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
                {
                    String sName(aSelectionLB.GetSelectEntry());
                    String sName(m_pSelectionLB->GetSelectEntry());
                    if (!IsFldEdit())
                        aNameED.SetText(sName);
                        m_pNameED->SetText(sName);

                    // is there a corresponding SetField
                    SwWrtShell *pSh = GetWrtShell();
@@ -382,7 +385,7 @@
            break;

        case TYP_INPUTFLD:
            aValueFT.SetText(SW_RESSTR(STR_PROMPT));
            m_pValueFT->SetText(SW_RESSTR(STR_PROMPT));

            if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
            {
@@ -390,8 +393,8 @@

                String sName;

                sName = aSelectionLB.GetSelectEntry();
                aNameED.SetText( sName );
                sName = m_pSelectionLB->GetSelectEntry();
                m_pNameED->SetText( sName );

                // User- or SetField ?
                sal_uInt16 nInpType = 0;
@@ -407,15 +410,15 @@
                    {
                        if (pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING)    // textual?
                        {
                            aNumFormatLB.Clear();
                            m_pNumFormatLB->Clear();

                            sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_USERVAR_TEXT), 0);
                            aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
                            aNumFormatLB.SelectEntryPos(0);
                            sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_USERVAR_TEXT), 0);
                            m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
                            m_pNumFormatLB->SelectEntryPos(0);
                        }
                    }
                    if (IsFldEdit() && (!pBox || bInit) )
                        aValueED.SetText(((SwSetExpField*)GetCurField())->GetPromptText());
                        m_pValueED->SetText(((SwSetExpField*)GetCurField())->GetPromptText());
                }
                else    // USERFLD
                    bFormat = bNumFmt = sal_False;
@@ -423,7 +426,7 @@
            break;

        case TYP_DDEFLD:
            aValueFT.SetText(SW_RESSTR(STR_DDE_CMD));
            m_pValueFT->SetText(SW_RESSTR(STR_DDE_CMD));

            if (IsFldEdit() || pBox)    // only when interacting via mouse
            {
@@ -434,7 +437,7 @@

                    if(pType)
                    {
                        aNameED.SetText(pType->GetName());
                        m_pNameED->SetText(pType->GetName());

                        //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
                        //              That's not considered here yet
@@ -442,8 +445,8 @@
                        sal_uInt16 nTmpPos = sCmd.SearchAndReplace( sfx2::cTokenSeparator, ' ' );
                        sCmd.SearchAndReplace( sfx2::cTokenSeparator, ' ', nTmpPos );

                        aValueED.SetText( sCmd );
                        aFormatLB.SelectEntryPos(pType->GetType());
                        m_pValueED->SetText( sCmd );
                        m_pFormatLB->SelectEntryPos(pType->GetType());
                    }
                }
            }
@@ -452,14 +455,14 @@

        case TYP_SEQFLD:
            {
                bName = bValue = bSeparator = bChapterLevel = sal_True;
                bName = bValue = bShowChapterFrame = true;

                SwFieldType* pFldTyp;
                if( IsFldEdit() )
                    pFldTyp = GetCurField()->GetTyp();
                else
                {
                    String sFldTypeName( aSelectionLB.GetEntry( nSelPos ));
                    String sFldTypeName( m_pSelectionLB->GetEntry( nSelPos ));
                    if( sFldTypeName.Len() )
                        pFldTyp = GetFldMgr().GetFldType( RES_SETEXPFLD,
                                                          sFldTypeName );
@@ -468,21 +471,21 @@
                }

                if( IsFldEdit() )
                    aValueED.SetText( ((SwSetExpField*)GetCurField())->
                    m_pValueED->SetText( ((SwSetExpField*)GetCurField())->
                                        GetFormula() );

                if( IsFldEdit() || pBox )   // only when interacting via mouse
                    aNameED.SetText( aSelectionLB.GetSelectEntry() );
                    m_pNameED->SetText( m_pSelectionLB->GetSelectEntry() );

                if( pFldTyp )
                {
                    sal_uInt8 nLevel = ((SwSetExpFieldType*)pFldTyp)->GetOutlineLvl();
                    if( 0x7f == nLevel )
                        aChapterLevelLB.SelectEntryPos( 0 );
                        m_pChapterLevelLB->SelectEntryPos( 0 );
                    else
                        aChapterLevelLB.SelectEntryPos( nLevel + 1 );
                        m_pChapterLevelLB->SelectEntryPos( nLevel + 1 );
                    String sDelim = ((SwSetExpFieldType*)pFldTyp)->GetDelimiter();
                    aSeparatorED.SetText( sDelim );
                    m_pSeparatorED->SetText( sDelim );
                    ChapterHdl();
                }
            }
@@ -491,83 +494,69 @@
        case TYP_SETREFPAGEFLD:
            {
                bValue = sal_False;
                aValueFT.SetText( SW_RESSTR( STR_OFFSET ));
                m_pValueFT->SetText( SW_RESSTR( STR_OFFSET ));

                if (IsFldEdit() || pBox)    // only when interacting via mouse
                    aNameED.SetText(aEmptyStr);
                    m_pNameED->SetText(aEmptyStr);

                if (nSelPos != 0 && nSelPos != LISTBOX_ENTRY_NOTFOUND)
                {
                    bValue = sal_True;      // SubType OFF - knows no Offset
                    if (IsFldEdit())
                        aValueED.SetText(OUString::number(((SwRefPageSetField*)GetCurField())->GetOffset()));
                        m_pValueED->SetText(OUString::number(((SwRefPageSetField*)GetCurField())->GetOffset()));
                }
            }
            break;

        case TYP_GETREFPAGEFLD:
            aNameED.SetText(aEmptyStr);
            aValueED.SetText(aEmptyStr);
            m_pNameED->SetText(aEmptyStr);
            m_pValueED->SetText(aEmptyStr);
            break;
    }

    aNumFormatLB.Show(bNumFmt);
    aFormatLB.Show(!bNumFmt);
    m_pNumFormatLB->Show(bNumFmt);
    m_pFormatLB->Show(!bNumFmt);

    if (IsFldEdit())
        bName = sal_False;

    aFormatLB.Enable(bFormat);
    aFormatFT.Enable(bFormat|bNumFmt);
    aNameFT.Enable(bName);
    aNameED.Enable(bName);
    aValueFT.Enable(bValue);
    aValueED.Enable(bValue);
    m_pFormat->Enable(bFormat|bNumFmt);
    m_pNameFT->Enable(bName);
    m_pNameED->Enable(bName);
    m_pValueFT->Enable(bValue);
    m_pValueED->Enable(bValue);

    Size aSz(aFormatLB.GetSizePixel());

    if (bChapterLevel)
        aSz.Height() = aFormatLB.LogicToPixel(Size(1, 94), MAP_APPFONT).Height();
    else
        aSz.Height() = aFormatLB.LogicToPixel(Size(1, 123), MAP_APPFONT).Height();

    aFormatLB.SetSizePixel(aSz);

    aInvisibleCB.Show(!bSeparator);
    aSeparatorFT.Show(bSeparator);
    aSeparatorED.Show(bSeparator);
    aChapterHeaderFT.Show(bChapterLevel);
    aChapterLevelFT.Show(bChapterLevel);
    aChapterLevelLB.Show(bChapterLevel);
    aInvisibleCB.Enable(bInvisible);
    m_pInvisibleCB->Show(!bShowChapterFrame);
    m_pChapterFrame->Show(bShowChapterFrame);
    m_pInvisibleCB->Enable(bInvisible);

    ModifyHdl();    // apply/insert/delete status update

    aNumFormatLB.SetUpdateMode(sal_True);
    aFormatLB.SetUpdateMode(sal_True);
    m_pNumFormatLB->SetUpdateMode(sal_True);
    m_pFormatLB->SetUpdateMode(sal_True);

    if(aSelectionLB.IsCallAddSelection())
    if(m_pSelectionLB->IsCallAddSelection())
    {
        nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
        nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());

        switch (nTypeId)
        {
            case TYP_FORMELFLD:
                {
                    nSelPos = aSelectionLB.GetSelectEntryPos();
                    nSelPos = m_pSelectionLB->GetSelectEntryPos();

                    if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
                        nSelPos = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSelPos);
                        nSelPos = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nSelPos);

                    if (nSelPos != LISTBOX_ENTRY_NOTFOUND && pBox && !bInit)
                    {
                        aValueED.ReplaceSelected(aSelectionLB.GetSelectEntry());
                        m_pValueED->ReplaceSelected(m_pSelectionLB->GetSelectEntry());
                        ModifyHdl();
                    }
                }
                break;
        }
        aSelectionLB.ResetCallAddSelection();
        m_pSelectionLB->ResetCallAddSelection();
    }
    return 0;
}
@@ -578,15 +567,15 @@
void SwFldVarPage::UpdateSubType()
{
    String sOldSel;
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());

    SetSelectionSel(aSelectionLB.GetSelectEntryPos());
    SetSelectionSel(m_pSelectionLB->GetSelectEntryPos());
    if(GetSelectionSel() != LISTBOX_ENTRY_NOTFOUND)
        sOldSel = aSelectionLB.GetEntry(GetSelectionSel());
        sOldSel = m_pSelectionLB->GetEntry(GetSelectionSel());

    // fill Selection-Listbox
    aSelectionLB.SetUpdateMode(sal_False);
    aSelectionLB.Clear();
    m_pSelectionLB->SetUpdateMode(sal_False);
    m_pSelectionLB->Clear();

    std::vector<OUString> aList;
    GetFldMgr().GetSubTypes(nTypeId, aList);
@@ -599,8 +588,8 @@
        {
            if (!IsFldEdit())
            {
                nPos = aSelectionLB.InsertEntry(aList[i]);
                aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
                nPos = m_pSelectionLB->InsertEntry(aList[i]);
                m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
            }
            else
            {
@@ -628,7 +617,7 @@
                        {
                            bInsert = sal_True;
                            if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)
                                aInvisibleCB.Check();
                                m_pInvisibleCB->Check();
                        }
                        break;

@@ -638,8 +627,8 @@
                            sOldSel = aList[i];

                        // allow all entries for selection:
                        nPos = aSelectionLB.InsertEntry(aList[i]);
                        aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
                        nPos = m_pSelectionLB->InsertEntry(aList[i]);
                        m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
                        break;

                    default:
@@ -649,8 +638,8 @@
                }
                if (bInsert)
                {
                    nPos = aSelectionLB.InsertEntry(aList[i]);
                    aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
                    nPos = m_pSelectionLB->InsertEntry(aList[i]);
                    m_pSelectionLB->SetEntryData(nPos, reinterpret_cast<void*>(i));
                    if (nTypeId != TYP_FORMELFLD)
                        break;
                }
@@ -658,24 +647,23 @@
        }
    }

    sal_Bool bEnable = aSelectionLB.GetEntryCount() != 0;
    sal_Bool bEnable = m_pSelectionLB->GetEntryCount() != 0;
    ListBox *pLB = 0;

    if (bEnable)
    {
        aSelectionLB.SelectEntry(sOldSel);
        if (!aSelectionLB.GetSelectEntryCount())
        m_pSelectionLB->SelectEntry(sOldSel);
        if (!m_pSelectionLB->GetSelectEntryCount())
        {
            aSelectionLB.SelectEntryPos(0);
            pLB = &aSelectionLB;    // newly initialise all controls
            m_pSelectionLB->SelectEntryPos(0);
            pLB = m_pSelectionLB;    // newly initialise all controls
        }
    }

    aSelectionLB.Enable( bEnable );
    aSelectionFT.Enable( bEnable );
    m_pSelection->Enable(bEnable);

    SubTypeHdl(pLB);
    aSelectionLB.SetUpdateMode(sal_True);
    m_pSelectionLB->SetUpdateMode(sal_True);
}

sal_uInt16 SwFldVarPage::FillFormatLB(sal_uInt16 nTypeId)
@@ -683,20 +671,20 @@
    String sOldSel, sOldNumSel;
    sal_uLong nOldNumFormat = 0;

    sal_uInt16 nFormatSel = aFormatLB.GetSelectEntryPos();
    sal_uInt16 nFormatSel = m_pFormatLB->GetSelectEntryPos();
    if (nFormatSel != LISTBOX_ENTRY_NOTFOUND)
        sOldSel = aFormatLB.GetEntry(nFormatSel);
        sOldSel = m_pFormatLB->GetEntry(nFormatSel);

    sal_uInt16 nNumFormatSel = aNumFormatLB.GetSelectEntryPos();
    sal_uInt16 nNumFormatSel = m_pNumFormatLB->GetSelectEntryPos();
    if (nNumFormatSel != LISTBOX_ENTRY_NOTFOUND)
    {
        sOldNumSel = aNumFormatLB.GetEntry(nNumFormatSel);
        nOldNumFormat = aNumFormatLB.GetFormat();
        sOldNumSel = m_pNumFormatLB->GetEntry(nNumFormatSel);
        nOldNumFormat = m_pNumFormatLB->GetFormat();
    }

    // fill Format-Listbox
    aFormatLB.Clear();
    aNumFormatLB.Clear();
    m_pFormatLB->Clear();
    m_pNumFormatLB->Clear();
    sal_Bool bSpecialFmt = sal_False;

    if( TYP_GETREFPAGEFLD != nTypeId )
@@ -707,19 +695,19 @@

            if (!bSpecialFmt)
            {
                aNumFormatLB.SetDefFormat(GetCurField()->GetFormat());
                m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
                sOldNumSel = aEmptyStr;
            }
            else
                if (nTypeId == TYP_GETFLD || nTypeId == TYP_FORMELFLD)
                    aNumFormatLB.SetFormatType(NUMBERFORMAT_NUMBER);
                    m_pNumFormatLB->SetFormatType(NUMBERFORMAT_NUMBER);
        }
        else
        {
            if (nOldNumFormat && nOldNumFormat != ULONG_MAX)
                aNumFormatLB.SetDefFormat(nOldNumFormat);
                m_pNumFormatLB->SetDefFormat(nOldNumFormat);
            else
                aNumFormatLB.SetFormatType(NUMBERFORMAT_NUMBER);
                m_pNumFormatLB->SetFormatType(NUMBERFORMAT_NUMBER);
        }
    }

@@ -729,10 +717,10 @@
        {
            if (!IsFldEdit() || bSpecialFmt)
            {
                sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_MARK_TEXT), 0);
                aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
                nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_USERVAR_CMD), 1);
                aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
                sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_MARK_TEXT), 0);
                m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
                nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_USERVAR_CMD), 1);
                m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
            }
        }
        break;
@@ -741,23 +729,23 @@
        {
            if (!IsFldEdit() || bSpecialFmt)
            {
                sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0);
                aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
                sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_SETVAR_TEXT), 0);
                m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
            }
        }
        break;

        case TYP_FORMELFLD:
        {
            sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0);
            aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
            sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0);
            m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
        }
        break;

        case TYP_GETFLD:
        {
            sal_uInt16 nPos = aNumFormatLB.InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0);
            aNumFormatLB.SetEntryData(nPos, (void *)ULONG_MAX);
            sal_uInt16 nPos = m_pNumFormatLB->InsertEntry(SW_RESSTR(FMT_GETVAR_NAME), 0);
            m_pNumFormatLB->SetEntryData(nPos, (void *)ULONG_MAX);
        }
        break;
    }
@@ -765,41 +753,41 @@
    if (IsFldEdit() && bSpecialFmt)
    {
        if (nTypeId == TYP_USERFLD && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD))
            aNumFormatLB.SelectEntryPos(1);
            m_pNumFormatLB->SelectEntryPos(1);
        else
            aNumFormatLB.SelectEntryPos(0);
            m_pNumFormatLB->SelectEntryPos(0);
    }
    else
    {
        if (!nOldNumFormat && (nNumFormatSel = aNumFormatLB.GetEntryPos(sOldNumSel)) != LISTBOX_ENTRY_NOTFOUND)
            aNumFormatLB.SelectEntryPos(nNumFormatSel);
        if (!nOldNumFormat && (nNumFormatSel = m_pNumFormatLB->GetEntryPos(sOldNumSel)) != LISTBOX_ENTRY_NOTFOUND)
            m_pNumFormatLB->SelectEntryPos(nNumFormatSel);
        else if (nOldNumFormat && nOldNumFormat == ULONG_MAX)
            aNumFormatLB.SelectEntry(sOldSel);
            m_pNumFormatLB->SelectEntry(sOldSel);
    }

    sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, false, IsFldDlgHtmlMode());

    for (sal_uInt16 i = 0; i < nSize; i++)
    {
        sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
        sal_uInt16 nPos = m_pFormatLB->InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
        sal_uInt16 nFldId = GetFldMgr().GetFormatId( nTypeId, i );
        aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(nFldId) );
        m_pFormatLB->SetEntryData( nPos, reinterpret_cast<void*>(nFldId) );
        if (IsFldEdit() && nFldId == GetCurField()->GetFormat())
            aFormatLB.SelectEntryPos( nPos );
            m_pFormatLB->SelectEntryPos( nPos );
    }

    if (nSize && (!IsFldEdit() || !aFormatLB.GetSelectEntryCount()))
    if (nSize && (!IsFldEdit() || !m_pFormatLB->GetSelectEntryCount()))
    {
        aFormatLB.SelectEntry(sOldSel);
        m_pFormatLB->SelectEntry(sOldSel);

        if (!aFormatLB.GetSelectEntryCount())
        if (!m_pFormatLB->GetSelectEntryCount())
        {
            aFormatLB.SelectEntry(SW_RESSTR(FMT_NUM_PAGEDESC));
            if (!aFormatLB.GetSelectEntryCount())
            m_pFormatLB->SelectEntry(SW_RESSTR(FMT_NUM_PAGEDESC));
            if (!m_pFormatLB->GetSelectEntryCount())
            {
                aFormatLB.SelectEntry(SW_RESSTR(FMT_NUM_ARABIC));
                if (!aFormatLB.GetSelectEntryCount())
                    aFormatLB.SelectEntryPos(0);
                m_pFormatLB->SelectEntry(SW_RESSTR(FMT_NUM_ARABIC));
                if (!m_pFormatLB->GetSelectEntryCount())
                    m_pFormatLB->SelectEntryPos(0);
            }
        }
    }
@@ -812,12 +800,12 @@
 --------------------------------------------------------------------*/
IMPL_LINK_NOARG(SwFldVarPage, ModifyHdl)
{
    String sValue(aValueED.GetText());
    String sValue(m_pValueED->GetText());
    sal_Bool bHasValue = sValue.Len() != 0;
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());
    bool bInsert = false, bApply = false, bDelete = false;

    String sName( aNameED.GetText() );
    String sName( m_pNameED->GetText() );
    xub_StrLen nLen = sName.Len();

    switch( nTypeId )
@@ -830,9 +818,9 @@
        if( sName.Len() != nLen )
        {
            nLen = sName.Len();
            Selection aSel(aNameED.GetSelection());
            aNameED.SetText( sName );
            aNameED.SetSelection( aSel );   // restore Cursorpos
            Selection aSel(m_pNameED->GetSelection());
            m_pNameED->SetText( sName );
            m_pNameED->SetSelection( aSel );   // restore Cursorpos
        }
        break;
    }
@@ -929,8 +917,8 @@
        break;
    }

    aNewDelTBX.EnableItem(BT_VARAPPLY, bApply);
    aNewDelTBX.EnableItem(BT_VARDELETE, bDelete);
    m_pNewDelTBX->EnableItem(m_nApplyId, bApply);
    m_pNewDelTBX->EnableItem(m_nDeleteId, bDelete);
    EnableInsert(bInsert);

    return 0;
@@ -938,123 +926,83 @@

IMPL_LINK( SwFldVarPage, TBClickHdl, ToolBox *, pBox )
{
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());

    switch (pBox->GetCurItemId())
    sal_uInt16 nCurId = pBox->GetCurItemId();

    if (nCurId == m_nDeleteId)
    {
        case BT_VARDELETE:
        if( nTypeId == TYP_USERFLD )
            GetFldMgr().RemoveFldType(RES_USERFLD, m_pSelectionLB->GetSelectEntry());
        else
        {
            if( nTypeId == TYP_USERFLD )
                GetFldMgr().RemoveFldType(RES_USERFLD, aSelectionLB.GetSelectEntry());
            else
            sal_uInt16 nWhich;

            switch(nTypeId)
            {
                sal_uInt16 nWhich;

                switch(nTypeId)
                {
                    case TYP_SETFLD:
                    case TYP_SEQFLD:
                        nWhich = RES_SETEXPFLD;
                        break;
                    default:
                        nWhich = RES_DDEFLD;
                        break;
                }

                GetFldMgr().RemoveFldType(nWhich, aSelectionLB.GetSelectEntry());
                case TYP_SETFLD:
                case TYP_SEQFLD:
                    nWhich = RES_SETEXPFLD;
                    break;
                default:
                    nWhich = RES_DDEFLD;
                    break;
            }

            UpdateSubType();
            GetFldMgr().RemoveFldType(nWhich, m_pSelectionLB->GetSelectEntry());
        }

        UpdateSubType();
        SwWrtShell *pSh = GetWrtShell();
        if(!pSh)
            pSh = ::GetActiveWrtShell();
        if(pSh)
        {
            pSh->SetModified();
        }
    }
    else if (nCurId == m_nApplyId)
    {
        String sName(m_pNameED->GetText()), sValue(m_pValueED->GetText());
        SwFieldType* pType = 0;
        sal_uInt16 nId = 0;
        sal_uInt16 nNumFormatPos = m_pNumFormatLB->GetSelectEntryPos();

        switch (nTypeId)
        {
            case TYP_USERFLD:   nId = RES_USERFLD;  break;
            case TYP_DDEFLD:    nId = RES_DDEFLD;   break;
            case TYP_SETFLD:    nId = RES_SETEXPFLD;break;
        }
        pType = GetFldMgr().GetFldType(nId, sName);

        sal_uLong nFormat = m_pFormatLB->GetSelectEntryPos();
        if (nFormat != LISTBOX_ENTRY_NOTFOUND)
            nFormat = (sal_uLong)m_pFormatLB->GetEntryData((sal_uInt16)nFormat);

        if (pType)  // change
        {
            SwWrtShell *pSh = GetWrtShell();
            if(!pSh)
                pSh = ::GetActiveWrtShell();
            if(pSh)
            {
                pSh->SetModified();
            }
        }
        break;
                pSh->StartAllAction();

        case BT_VARAPPLY:
        {
            String sName(aNameED.GetText()), sValue(aValueED.GetText());
            SwFieldType* pType = 0;
            sal_uInt16 nId = 0;
            sal_uInt16 nNumFormatPos = aNumFormatLB.GetSelectEntryPos();

            switch (nTypeId)
            {
                case TYP_USERFLD:   nId = RES_USERFLD;  break;
                case TYP_DDEFLD:    nId = RES_DDEFLD;   break;
                case TYP_SETFLD:    nId = RES_SETEXPFLD;break;
            }
            pType = GetFldMgr().GetFldType(nId, sName);

            sal_uLong nFormat = aFormatLB.GetSelectEntryPos();
            if (nFormat != LISTBOX_ENTRY_NOTFOUND)
                nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat);

            if (pType)  // change
            {
                SwWrtShell *pSh = GetWrtShell();
                if(!pSh)
                    pSh = ::GetActiveWrtShell();
                if(pSh)
                if (nTypeId == TYP_USERFLD)
                {
                    pSh->StartAllAction();

                    if (nTypeId == TYP_USERFLD)
                    if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND)
                    {
                        if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND)
                        {
                            sal_uLong nFmt = nNumFormatPos == 0 ? 0 : aNumFormatLB.GetFormat();
                            if (nFmt)
                            {   // Switch language to office-language because Kalkulator expects
                                // String in office format and it should be fed into dialog like
                                // that
                                nFmt = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFmt);
                            }
                            ((SwUserFieldType*)pType)->SetContent(aValueED.GetText(), nFmt);
                            ((SwUserFieldType*)pType)->SetType(
                                nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR );
                        sal_uLong nFmt = nNumFormatPos == 0 ? 0 : m_pNumFormatLB->GetFormat();
                        if (nFmt)
                        {   // Switch language to office-language because Kalkulator expects
                            // String in office format and it should be fed into dialog like
                            // that
                            nFmt = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFmt);
                        }
                    }
                    else
                    {
                        if (nFormat != LISTBOX_ENTRY_NOTFOUND)
                        {
                            // DDE-Topics/-Items can have blanks in their names!
                            //  That's not being considered here yet.
                            sal_uInt16 nTmpPos = sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator );
                            sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator, nTmpPos );
                            ((SwDDEFieldType*)pType)->SetCmd(sValue);
                            ((SwDDEFieldType*)pType)->SetType((sal_uInt16)nFormat);
                        }
                    }
                    pType->UpdateFlds();

                    pSh->EndAllAction();
                }
            }
            else        // new
            {
                if(nTypeId == TYP_USERFLD)
                {
                    SwWrtShell *pSh = GetWrtShell();
                    if(!pSh)
                        pSh = ::GetActiveWrtShell();
                    if(pSh)
                    {
                        SwUserFieldType aType( pSh->GetDoc(), sName );

                        if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND)
                        {
                            aType.SetType(nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR);
                            aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : aNumFormatLB.GetFormat() );
                            aSelectionLB.InsertEntry(sName);
                            aSelectionLB.SelectEntry(sName);
                            GetFldMgr().InsertFldType( aType ); // Userfld new
                        }
                        ((SwUserFieldType*)pType)->SetContent(m_pValueED->GetText(), nFmt);
                        ((SwUserFieldType*)pType)->SetType(
                            nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR );
                    }
                }
                else
@@ -1065,20 +1013,56 @@
                        //  That's not being considered here yet.
                        sal_uInt16 nTmpPos = sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator );
                        sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator, nTmpPos );
                        ((SwDDEFieldType*)pType)->SetCmd(sValue);
                        ((SwDDEFieldType*)pType)->SetType((sal_uInt16)nFormat);
                    }
                }
                pType->UpdateFlds();

                        SwDDEFieldType aType(sName, sValue, (sal_uInt16)nFormat);
                        aSelectionLB.InsertEntry(sName);
                        aSelectionLB.SelectEntry(sName);
                        GetFldMgr().InsertFldType(aType);   // DDE-Field new
                pSh->EndAllAction();
            }
        }
        else        // new
        {
            if(nTypeId == TYP_USERFLD)
            {
                SwWrtShell *pSh = GetWrtShell();
                if(!pSh)
                    pSh = ::GetActiveWrtShell();
                if(pSh)
                {
                    SwUserFieldType aType( pSh->GetDoc(), sName );

                    if (nNumFormatPos != LISTBOX_ENTRY_NOTFOUND)
                    {
                        aType.SetType(nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR);
                        aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : m_pNumFormatLB->GetFormat() );
                        m_pSelectionLB->InsertEntry(sName);
                        m_pSelectionLB->SelectEntry(sName);
                        GetFldMgr().InsertFldType( aType ); // Userfld new
                    }
                }
            }
            if (IsFldEdit())
                GetFldMgr().GetCurFld();    // update FieldManager
            else
            {
                if (nFormat != LISTBOX_ENTRY_NOTFOUND)
                {
                    // DDE-Topics/-Items can have blanks in their names!
                    //  That's not being considered here yet.
                    sal_uInt16 nTmpPos = sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator );
                    sValue.SearchAndReplace( ' ', sfx2::cTokenSeparator, nTmpPos );

            UpdateSubType();
                    SwDDEFieldType aType(sName, sValue, (sal_uInt16)nFormat);
                    m_pSelectionLB->InsertEntry(sName);
                    m_pSelectionLB->SelectEntry(sName);
                    GetFldMgr().InsertFldType(aType);   // DDE-Field new
                }
            }
        }
        break;
        if (IsFldEdit())
            GetFldMgr().GetCurFld();    // update FieldManager

        UpdateSubType();
    }

    return sal_True;
@@ -1086,10 +1070,10 @@

IMPL_LINK_NOARG(SwFldVarPage, ChapterHdl)
{
    sal_Bool bEnable = aChapterLevelLB.GetSelectEntryPos() != 0;
    sal_Bool bEnable = m_pChapterLevelLB->GetSelectEntryPos() != 0;

    aSeparatorED.Enable(bEnable);
    aSeparatorFT.Enable(bEnable);
    m_pSeparatorED->Enable(bEnable);
    m_pSeparatorFT->Enable(bEnable);
    SeparatorHdl();

    return 0;
@@ -1097,8 +1081,8 @@

IMPL_LINK_NOARG(SwFldVarPage, SeparatorHdl)
{
    sal_Bool bEnable = !aSeparatorED.GetText().isEmpty() ||
                    aChapterLevelLB.GetSelectEntryPos() == 0;
    sal_Bool bEnable = !m_pSeparatorED->GetText().isEmpty() ||
                    m_pChapterLevelLB->GetSelectEntryPos() == 0;
    EnableInsert(bEnable);

    return 0;
@@ -1106,33 +1090,33 @@

sal_Bool SwFldVarPage::FillItemSet(SfxItemSet& )
{
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
    sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel());

    String aVal(aValueED.GetText());
    String aName(aNameED.GetText());
    String aVal(m_pValueED->GetText());
    String aName(m_pNameED->GetText());

    sal_uInt16 nSubType = aSelectionLB.GetSelectEntryPos();
    sal_uInt16 nSubType = m_pSelectionLB->GetSelectEntryPos();
    if(nSubType == LISTBOX_ENTRY_NOTFOUND)
        nSubType = 0;
    else
        nSubType = (sal_uInt16)(sal_uLong)aSelectionLB.GetEntryData(nSubType);
        nSubType = (sal_uInt16)(sal_uLong)m_pSelectionLB->GetEntryData(nSubType);

    sal_uLong nFormat;

    if (!aNumFormatLB.IsVisible())
    if (!m_pNumFormatLB->IsVisible())
    {
        nFormat = aFormatLB.GetSelectEntryPos();
        nFormat = m_pFormatLB->GetSelectEntryPos();

        if(nFormat == LISTBOX_ENTRY_NOTFOUND)
            nFormat = 0;
        else
            nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat);
            nFormat = (sal_uLong)m_pFormatLB->GetEntryData((sal_uInt16)nFormat);
    }
    else
    {
        nFormat = aNumFormatLB.GetFormat();
        nFormat = m_pNumFormatLB->GetFormat();

        if (nFormat && nFormat != ULONG_MAX && aNumFormatLB.IsAutomaticLanguage())
        if (nFormat && nFormat != ULONG_MAX && m_pNumFormatLB->IsAutomaticLanguage())
        {
            // Switch language to office language because Kalkulator expects
            // String in office format and it should be fed into the dialog
@@ -1153,24 +1137,24 @@
        {
            nSubType = (nFormat == ULONG_MAX) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR;

            if (nFormat == ULONG_MAX && aNumFormatLB.GetSelectEntry() == SW_RESSTR(FMT_USERVAR_CMD))
            if (nFormat == ULONG_MAX && m_pNumFormatLB->GetSelectEntry() == SW_RESSTR(FMT_USERVAR_CMD))
                nSubType |= nsSwExtendedSubType::SUB_CMD;

            if (aInvisibleCB.IsChecked())
            if (m_pInvisibleCB->IsChecked())
                nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
            break;
        }
        case TYP_FORMELFLD:
        {
            nSubType = nsSwGetSetExpType::GSE_FORMULA;
            if (aNumFormatLB.IsVisible() && nFormat == ULONG_MAX)
            if (m_pNumFormatLB->IsVisible() && nFormat == ULONG_MAX)
                nSubType |= nsSwExtendedSubType::SUB_CMD;
            break;
        }
        case TYP_GETFLD:
        {
            nSubType &= 0xff00;
            if (aNumFormatLB.IsVisible() && nFormat == ULONG_MAX)
            if (m_pNumFormatLB->IsVisible() && nFormat == ULONG_MAX)
                nSubType |= nsSwExtendedSubType::SUB_CMD;
            break;
        }
@@ -1191,41 +1175,41 @@
            else
                nSubType = (nSubType & 0xff00) | ((nFormat == ULONG_MAX) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR);

            if (aInvisibleCB.IsChecked())
            if (m_pInvisibleCB->IsChecked())
                nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
            break;
        }
        case TYP_SEQFLD:
        {
            nSubType = aChapterLevelLB.GetSelectEntryPos();
            nSubType = m_pChapterLevelLB->GetSelectEntryPos();
            if (nSubType == 0)
                nSubType = 0x7f;
            else
            {
                nSubType--;
                OUString sSeparator = OUString(aSeparatorED.GetText()[0]);
                OUString sSeparator = OUString(m_pSeparatorED->GetText()[0]);
                cSeparator = !sSeparator.isEmpty() ? sSeparator[0] : ' ';
            }
            break;
        }
        case TYP_GETREFPAGEFLD:
            if( SVX_NUM_CHAR_SPECIAL == nFormat )
                aVal = aValueED.GetText();
                aVal = m_pValueED->GetText();
            break;
    }

    if (!IsFldEdit() ||
        aNameED.GetSavedValue() != aNameED.GetText() ||
        aValueED.GetSavedValue() != aValueED.GetText() ||
        aSelectionLB.GetSavedValue() != aSelectionLB.GetSelectEntryPos() ||
        aFormatLB.GetSavedValue() != aFormatLB.GetSelectEntryPos() ||
        nOldFormat != aNumFormatLB.GetFormat() ||
        aInvisibleCB.GetState() != aInvisibleCB.GetSavedValue() ||
        aChapterLevelLB.GetSavedValue() != aChapterLevelLB.GetSelectEntryPos() ||
        aSeparatorED.GetSavedValue() != aSeparatorED.GetText())
        m_pNameED->GetSavedValue() != m_pNameED->GetText() ||
        m_pValueED->GetSavedValue() != m_pValueED->GetText() ||
        m_pSelectionLB->GetSavedValue() != m_pSelectionLB->GetSelectEntryPos() ||
        m_pFormatLB->GetSavedValue() != m_pFormatLB->GetSelectEntryPos() ||
        nOldFormat != m_pNumFormatLB->GetFormat() ||
        m_pInvisibleCB->GetState() != m_pInvisibleCB->GetSavedValue() ||
        m_pChapterLevelLB->GetSavedValue() != m_pChapterLevelLB->GetSelectEntryPos() ||
        m_pSeparatorED->GetSavedValue() != m_pSeparatorED->GetText())
    {
        InsertFld( nTypeId, nSubType, aName, aVal, nFormat,
                    cSeparator, aNumFormatLB.IsAutomaticLanguage() );
                    cSeparator, m_pNumFormatLB->IsAutomaticLanguage() );
    }

    UpdateSubType();
@@ -1244,12 +1228,31 @@
    return GRP_VAR;
}

SelectionListBox::SelectionListBox( SwFldVarPage* pDialog, const ResId& rResId ) :
    ListBox (pDialog, rResId),
    bCallAddSelection(false)
SelectionListBox::SelectionListBox(Window* pParent, WinBits nStyle)
    : ListBox(pParent, nStyle)
    , bCallAddSelection(false)
{
}

extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSelectionListBox(Window *pParent, VclBuilder::stringmap &rMap)
{
    WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK;

    bool bDropdown = VclBuilder::extractDropdown(rMap);

    if (bDropdown)
        nBits |= WB_DROPDOWN;

    OString sBorder = VclBuilder::extractCustomProperty(rMap);
    if (!sBorder.isEmpty())
       nBits |= WB_BORDER;

    SelectionListBox* pListBox = new SelectionListBox(pParent, nBits|WB_SIMPLEMODE);
    pListBox->EnableAutoSize(true);

    return pListBox;
}

long SelectionListBox::PreNotify( NotifyEvent& rNEvt )
{
    long nHandled = ListBox::PreNotify( rNEvt );
@@ -1276,11 +1279,11 @@
{
    String sData(OUString(USER_DATA_VERSION));
    sData += ';';
    sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
    sal_uInt16 nTypeSel = m_pTypeLB->GetSelectEntryPos();
    if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
        nTypeSel = USHRT_MAX;
    else
        nTypeSel = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData( nTypeSel );
        nTypeSel = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData( nTypeSel );
    sData += OUString::number( nTypeSel );
    SetUserData(sData);
}
diff --git a/sw/source/ui/fldui/fldvar.hxx b/sw/source/ui/fldui/fldvar.hxx
index 3df2573..ce340a6 100644
--- a/sw/source/ui/fldui/fldvar.hxx
+++ b/sw/source/ui/fldui/fldvar.hxx
@@ -37,10 +37,10 @@
{
    bool            bCallAddSelection;

    virtual long        PreNotify( NotifyEvent& rNEvt );
    virtual long    PreNotify( NotifyEvent& rNEvt );

public:
    SelectionListBox( SwFldVarPage* pDialog, const ResId& rResId );
    SelectionListBox(Window* pParent, WinBits nStyle);

    //  detect selection via Ctrl or Alt and evaluate with SelectHdl
    bool            IsCallAddSelection() const {return bCallAddSelection;}
@@ -51,24 +51,24 @@
{
    friend class SelectionListBox;

    FixedText           aTypeFT;
    ListBox             aTypeLB;
    FixedText           aSelectionFT;
    SelectionListBox    aSelectionLB;
    FixedText           aNameFT;
    Edit                aNameED;
    FixedText           aValueFT;
    ConditionEdit       aValueED;
    FixedText           aFormatFT;
    NumFormatListBox    aNumFormatLB;
    ListBox             aFormatLB;
    FixedText           aChapterHeaderFT;
    FixedText           aChapterLevelFT;
    ListBox             aChapterLevelLB;
    CheckBox            aInvisibleCB;
    FixedText           aSeparatorFT;
    Edit                aSeparatorED;
    ToolBox             aNewDelTBX;
    ListBox*            m_pTypeLB;
    VclContainer*       m_pSelection;
    SelectionListBox*   m_pSelectionLB;
    FixedText*          m_pNameFT;
    Edit*               m_pNameED;
    FixedText*          m_pValueFT;
    ConditionEdit*      m_pValueED;
    VclContainer*       m_pFormat;
    NumFormatListBox*   m_pNumFormatLB;
    ListBox*            m_pFormatLB;
    VclContainer*       m_pChapterFrame;
    ListBox*            m_pChapterLevelLB;
    CheckBox*           m_pInvisibleCB;
    FixedText*          m_pSeparatorFT;
    Edit*               m_pSeparatorED;
    ToolBox*            m_pNewDelTBX;
    sal_uInt16          m_nApplyId;
    sal_uInt16          m_nDeleteId;

    String              sOldValueFT;
    String              sOldNameFT;
diff --git a/sw/source/ui/fldui/fldvar.src b/sw/source/ui/fldui/fldvar.src
deleted file mode 100644
index 3b93752..0000000
--- a/sw/source/ui/fldui/fldvar.src
+++ /dev/null
@@ -1,207 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include "globals.hrc"
#include "fldtdlg.hrc"
#include "helpid.h"
#include "cmdid.h"
TabPage TP_FLD_VAR
{
    HelpID = HID_FLD_VAR ;
    SVLook = TRUE ;
    Hide = TRUE ;
    Size = MAP_APPFONT ( TP_WIDTH , TP_HEIGHT ) ;
    FixedText FT_VARTYPE
    {
        Pos = MAP_APPFONT ( 6 , 3 ) ;
        Size = MAP_APPFONT ( 76 , 8 ) ;
        Text [ en-US ] = "~Type" ;
        Left = TRUE ;
    };
    ListBox LB_VARTYPE
    {
        HelpID = "sw:ListBox:TP_FLD_VAR:LB_VARTYPE";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 6 , 14 ) ;
        Size = MAP_APPFONT ( 76 , 135 ) ;
        TabStop = TRUE ;
        Sort = FALSE ;
        AutoHScroll = TRUE ;
    };
    FixedText FT_VARSELECTION
    {
        Pos = MAP_APPFONT ( 88 , 3 ) ;
        Size = MAP_APPFONT ( 76 , 8 ) ;
        Left = TRUE ;
        Text [ en-US ] = "S~election" ;
    };
    ListBox LB_VARSELECTION
    {
        HelpID = "sw:ListBox:TP_FLD_VAR:LB_VARSELECTION";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 88 , 14 ) ;
        Size = MAP_APPFONT ( 76 , 135 ) ;
        TabStop = TRUE ;
        Sort = TRUE ;
    };
    FixedText FT_VARFORMAT
    {
        Pos = MAP_APPFONT ( 170 , 3 ) ;
        Size = MAP_APPFONT ( 84 , 8 ) ;
        Left = TRUE ;
        Text [ en-US ] = "Format" ;
    };
    ListBox LB_VARFORMAT
    {
        HelpID = "sw:ListBox:TP_FLD_VAR:LB_VARFORMAT";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 170 , 14 ) ;
        Size = MAP_APPFONT ( 84 , 123 ) ;
        TabStop = TRUE ;
        DropDown = FALSE ;
    };
    ListBox LB_VARNUMFORMAT
    {
        HelpID = "sw:ListBox:TP_FLD_VAR:LB_VARNUMFORMAT";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 170 , 14 ) ;
        Size = MAP_APPFONT ( 84 , 123 ) ;
        TabStop = TRUE ;
        DropDown = FALSE ;
    };
    CheckBox CB_VARINVISIBLE
    {
        HelpID = "sw:CheckBox:TP_FLD_VAR:CB_VARINVISIBLE";
        Pos = MAP_APPFONT ( 170 , 141 ) ;
        Size = MAP_APPFONT ( 84 , 10 ) ;
        Text [ en-US ] = "Invisi~ble" ;
        TabStop = TRUE ;
    };
    FixedText FT_VARCHAPTERHEADER
    {
        Pos = MAP_APPFONT ( 170 , 112 ) ;
        Size = MAP_APPFONT ( 84 , 8 ) ;
        Hide = TRUE ;
        Text [ en-US ] = "Numbering by chapter" ;
    };
    FixedText FT_VARCHAPTERLEVEL
    {
        Pos = MAP_APPFONT ( 175 , 125 ) ;
        Size = MAP_APPFONT ( 30 , 8 ) ;
        Hide = TRUE ;
        Text [ en-US ] = "~Level" ;
    };
    ListBox LB_VARCHAPTERLEVEL
    {
        HelpID = "sw:ListBox:TP_FLD_VAR:LB_VARCHAPTERLEVEL";
        Border = TRUE ;
        Hide = TRUE ;
        Pos = MAP_APPFONT ( 208 , 123 ) ;
        Size = MAP_APPFONT ( 46 , 76 ) ;
        TabStop = TRUE ;
        DropDown = TRUE ;
        StringList [ en-US ] =
        {
            < "None" ; > ;
        };
    };
    FixedText FT_VARSEPARATOR
    {
        Pos = MAP_APPFONT ( 175 , 140 ) ;
        Size = MAP_APPFONT ( 30 , 10 ) ;
        Hide = TRUE ;
        Text [ en-US ] = "~Separator" ;
    };
    Edit ED_VARSEPARATOR
    {
        HelpID = "sw:Edit:TP_FLD_VAR:ED_VARSEPARATOR";
        Pos = MAP_APPFONT ( 208 , 138 ) ;
        Size = MAP_APPFONT ( 46 , 12 ) ;
        Border = TRUE ;
        Hide = TRUE ;
        MaxTextLength = 1 ;
        TEXT = "." ;
    };
    FixedText FT_VARNAME
    {
        Pos = MAP_APPFONT ( 6 , 155 ) ;
        Size = MAP_APPFONT ( 76 , 8 ) ;
        Left = TRUE ;
        Text [ en-US ] = "Na~me" ;
    };
    Edit ED_VARNAME
    {
        HelpID = "sw:Edit:TP_FLD_VAR:ED_VARNAME";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 6 , 166 ) ;
        Size = MAP_APPFONT ( 76 , 12 ) ;
        TabStop = TRUE ;
        Left = TRUE ;
    };
    FixedText FT_VARVALUE
    {
        Pos = MAP_APPFONT ( 88 , 155 ) ;
        Size = MAP_APPFONT ( 76 , 8 ) ;
        Text [ en-US ] = "~Value" ;
        Left = TRUE ;
    };
    Edit ED_VARVALUE
    {
        HelpID = "sw:Edit:TP_FLD_VAR:ED_VARVALUE";
        Border = TRUE ;
        Pos = MAP_APPFONT ( 88 , 166 ) ;
        Size = MAP_APPFONT ( 76 , 12 ) ;
        TabStop = TRUE ;
        Left = TRUE ;
    };
    ToolBox TBX_VARNEWDEL
    {
        Pos = MAP_APPFONT ( 167 , 167 ) ;
        SVLook = TRUE ;
        Border = FALSE ;
        ItemList =
        {
            ToolBoxItem
            {
                Identifier = BT_VARAPPLY ;
                HelpID = HID_FLDVAR_APPLY ;
                ItemImage = Image
                {
                    ImageBitmap = Bitmap{ File = "sc20558.bmp" ;};
                    MaskColor = IMAGE_MASK_COLOR ;
                };
                Text [ en-US ] = "Apply" ;
            };
            ToolBoxItem
            {
                Identifier = BT_VARDELETE ;
                HelpID = HID_FLDVAR_DELETE ;
                ItemImage = Image
                {
                    ImageBitmap = Bitmap{ File = "sc20557.bmp" ;};
                    MaskColor = IMAGE_MASK_COLOR ;
                };
                Text [ en-US ] = "Delete" ;
            };
        };
    };
    Text [ en-US ] = "Variables" ;
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/fldvarpage.ui b/sw/uiconfig/swriter/ui/fldvarpage.ui
new file mode 100644
index 0000000..551920a
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/fldvarpage.ui
@@ -0,0 +1,567 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <!-- interface-requires LibreOffice 1.0 -->
  <object class="GtkBox" id="FldVarPage">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="spacing">12</property>
    <property name="homogeneous">True</property>
    <child>
      <object class="GtkBox" id="box3">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="vexpand">True</property>
        <property name="orientation">vertical</property>
        <property name="spacing">12</property>
        <child>
          <object class="GtkFrame" id="typeframe">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="label_xalign">0</property>
            <property name="shadow_type">none</property>
            <child>
              <object class="GtkAlignment" id="alignment1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="top_padding">6</property>
                <child>
                  <object class="GtkTreeView" id="type:border">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="model">liststore1</property>
                    <property name="search_column">0</property>
                    <child internal-child="selection">
                      <object class="GtkTreeSelection" id="treeview-selection3"/>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child type="label">
              <object class="GtkLabel" id="label1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">_Type</property>
                <property name="use_underline">True</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid" id="grid2">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="valign">end</property>
            <property name="row_spacing">6</property>
            <child>
              <object class="GtkLabel" id="nameft">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">Na_me</property>
                <property name="use_underline">True</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkEntry" id="name">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="valign">center</property>
                <property name="hexpand">True</property>
                <property name="invisible_char">•</property>
                <property name="invisible_char_set">True</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">0</property>
      </packing>
    </child>
    <child>
      <object class="GtkBox" id="box4">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="vexpand">True</property>
        <property name="orientation">vertical</property>
        <property name="spacing">12</property>
        <child>
          <object class="GtkFrame" id="selectframe">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="label_xalign">0</property>
            <property name="shadow_type">none</property>
            <child>
              <object class="GtkAlignment" id="alignment2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="top_padding">6</property>
                <child>
                  <object class="swuilo-SelectionListBox" id="select:border">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="dropdown">False</property>
                  </object>
                </child>
              </object>
            </child>
            <child type="label">
              <object class="GtkLabel" id="label2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">S_elect</property>
                <property name="use_underline">True</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid" id="grid3">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="valign">end</property>
            <property name="row_spacing">6</property>
            <child>
              <object class="GtkLabel" id="valueft">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes">_Value</property>
                <property name="use_underline">True</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
              <object class="swlo-ConditionEdit" id="value">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="valign">center</property>
                <property name="hexpand">True</property>
                <property name="invisible_char">•</property>
                <property name="invisible_char_set">True</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">1</property>
      </packing>
    </child>
    <child>
      <object class="GtkBox" id="box1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="vexpand">True</property>
        <property name="orientation">vertical</property>
        <property name="spacing">12</property>
        <child>
          <object class="GtkBox" id="box2">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="vexpand">True</property>
            <property name="orientation">vertical</property>
            <property name="spacing">12</property>
            <child>
              <object class="GtkFrame" id="formatframe">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="label_xalign">0</property>
                <property name="shadow_type">none</property>
                <child>
                  <object class="GtkAlignment" id="alignment3">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="top_padding">6</property>
                    <child>
                      <object class="GtkBox" id="box5">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="orientation">vertical</property>
                        <property name="spacing">6</property>
                        <child>
                          <object class="swlo-NumFormatListBox" id="numformat:border">
                            <property name="visible">True</property>
                            <property name="can_focus">True</property>
                            <property name="hexpand">True</property>
                            <property name="vexpand">True</property>
                            <property name="dropdown">False</property>
                          </object>
                          <packing>
                            <property name="expand">False</property>
                            <property name="fill">True</property>
                            <property name="position">0</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkTreeView" id="format:border">
                            <property name="visible">True</property>
                            <property name="can_focus">True</property>
                            <property name="hexpand">True</property>
                            <property name="vexpand">True</property>
                            <property name="model">liststore1</property>
                            <property name="search_column">0</property>
                            <child internal-child="selection">
                              <object class="GtkTreeSelection" id="treeview-selection2"/>
                            </child>
                          </object>
                          <packing>
                            <property name="expand">False</property>
                            <property name="fill">True</property>
                            <property name="position">1</property>
                          </packing>
                        </child>
                      </object>
                    </child>
                  </object>
                </child>
                <child type="label">
                  <object class="GtkLabel" id="label3">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="xalign">0</property>
                    <property name="label" translatable="yes">F_ormat</property>
                    <property name="use_underline">True</property>
                    <attributes>
                      <attribute name="weight" value="bold"/>
                    </attributes>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkCheckButton" id="invisible">
                <property name="label" translatable="yes">Invisi_ble</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">False</property>
                <property name="use_underline">True</property>
                <property name="xalign">0</property>
                <property name="draw_indicator">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkFrame" id="chapterframe">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="label_xalign">0</property>
                <property name="shadow_type">none</property>
                <child>
                  <object class="GtkAlignment" id="alignment4">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="top_padding">6</property>
                    <property name="left_padding">12</property>
                    <child>
                      <object class="GtkGrid" id="grid1">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="row_spacing">6</property>
                        <property name="column_spacing">12</property>
                        <child>
                          <object class="GtkLabel" id="label5">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="xalign">0</property>
                            <property name="label" translatable="yes">_Level</property>
                            <property name="use_underline">True</property>
                          </object>
                          <packing>
                            <property name="left_attach">0</property>
                            <property name="top_attach">0</property>
                            <property name="width">1</property>
                            <property name="height">1</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkLabel" id="separatorft">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="xalign">0</property>
                            <property name="label" translatable="yes">_Separator</property>
                            <property name="use_underline">True</property>
                            <property name="mnemonic_widget">separator</property>
                          </object>
                          <packing>
                            <property name="left_attach">0</property>
                            <property name="top_attach">1</property>
                            <property name="width">1</property>
                            <property name="height">1</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkComboBoxText" id="level">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="entry_text_column">0</property>
                            <property name="id_column">1</property>
                            <items>
                              <item translatable="yes">None</item>
                            </items>
                          </object>
                          <packing>
                            <property name="left_attach">1</property>
                            <property name="top_attach">0</property>
                            <property name="width">1</property>
                            <property name="height">1</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkEntry" id="separator">
                            <property name="visible">True</property>
                            <property name="can_focus">True</property>
                            <property name="max_length">1</property>
                            <property name="invisible_char">•</property>
                            <property name="width_chars">2</property>
                            <property name="text" translatable="yes">.</property>
                          </object>
                          <packing>
                            <property name="left_attach">1</property>
                            <property name="top_attach">1</property>
                            <property name="width">1</property>
                            <property name="height">1</property>
                          </packing>
                        </child>
                      </object>
                    </child>
                  </object>
                </child>
                <child type="label">
                  <object class="GtkLabel" id="label4">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="xalign">0</property>
                    <property name="label" translatable="yes">Numbering by chapter</property>
                    <property name="use_underline">True</property>
                    <attributes>
                      <attribute name="weight" value="bold"/>
                    </attributes>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkGrid" id="grid4">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="valign">end</property>
            <property name="row_spacing">6</property>
            <child>
              <object class="GtkToolbar" id="toolbar">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="valign">center</property>
                <property name="toolbar_style">icons</property>
                <child>
                  <object class="GtkToolButton" id="apply">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="has_tooltip">True</property>
                    <property name="tooltip_markup" translatable="yes">Apply</property>
                    <property name="tooltip_text" translatable="yes">Apply</property>
                    <property name="action_name">apply</property>
                    <property name="use_underline">True</property>
                    <property name="icon_name">svx/res/nu01.png</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkToolButton" id="delete">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="has_tooltip">True</property>
                    <property name="tooltip_markup" translatable="yes">Delete</property>
                    <property name="tooltip_text" translatable="yes">Delete</property>
                    <property name="action_name">delete</property>
                    <property name="use_underline">True</property>
                    <property name="icon_name">svx/res/nu02.png</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
                    <property name="homogeneous">True</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkGrid" id="grid5">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <child>
                  <placeholder/>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">0</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
      <packing>
        <property name="expand">False</property>
        <property name="fill">True</property>
        <property name="position">2</property>
      </packing>
    </child>
  </object>
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name gchararray1 -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes">Author</col>
      </row>
      <row>
        <col id="0" translatable="yes">Time</col>
      </row>
      <row>
        <col id="0" translatable="yes">Date</col>
      </row>
      <row>
        <col id="0" translatable="yes">Date Time Author</col>
      </row>
    </data>
  </object>
  <object class="GtkSizeGroup" id="sizegroup1">
    <property name="mode">both</property>
    <property name="ignore_hidden">True</property>
    <widgets>
      <widget name="type:border"/>
      <widget name="select:border"/>
    </widgets>
  </object>
  <object class="GtkSizeGroup" id="sizegroup2">
    <property name="mode">vertical</property>
    <widgets>
      <widget name="grid2"/>
      <widget name="grid3"/>
      <widget name="grid4"/>
    </widgets>
  </object>
  <object class="GtkSizeGroup" id="sizegroup3">
    <property name="mode">vertical</property>
    <widgets>
      <widget name="nameft"/>
      <widget name="valueft"/>
      <widget name="grid5"/>
    </widgets>
  </object>
</interface>